package com.Dec_Twentyfive;

import java.util.Arrays;

public class SolutionLCP50 {

    public int giveGem(int[] gem, int[][] operations) {
        int maxVal=gem[0],minVal=gem[0];
        for (int[] operation:operations){
            int temp=gem[operation[0]]/2;
            gem[operation[0]]-=temp;
            gem[operation[1]]+=temp;
        }
        for (int i = 0; i < gem.length; i++) {
            maxVal=Math.max(maxVal,gem[i]);
            minVal=Math.min(minVal,gem[i]);
        }
        return maxVal-minVal;
    }

    public static void main(String[] args) {
        SolutionLCP50 solutionLCP50=new SolutionLCP50();
        System.out.println(solutionLCP50.giveGem(new int[]{3,1,2},new int[][]{{0,2},{2,1},{2,0}}));
    }

}
